#pragma once
#include "cocos2d.h"
#include <iostream>

using namespace cocos2d;
using namespace std;

class SellCardSprite;
class BuyMoney : public Sprite
{
	virtual bool init() override;
	Label* m_pBuyMoneyLabel = nullptr;
	Label* m_pKLabel = nullptr;
	int m_nCurrentShowCount;

	Action* getBlinkAnmation();
public:
	void refreshMoney();
	void planToSpendMoney(int nMoney);

	CREATE_FUNC(BuyMoney);
};

class OperateBoard : public Layer
{
	~OperateBoard();

	virtual bool init() override;
	Sprite* m_pOperateBase;
	Sprite* m_pBuyOperateBase;
	Sprite* m_pBuyCardBase;
	Sprite* m_pSellOpearteBase;
	BuyMoney* m_pBuyMoney;
	Label* m_pMoneyPlanToLabel;
	Label* m_pMoneySumLable;
	vector<int> m_rgBuyCards;
	vector<Point> m_rgMyHourseCardPos;
	float m_flMyHourseCardScale;
	vector<Sprite*> m_rgSellHourseCardsVec;

	int m_nMoneyPlanTo = 0;
	int m_nLastMoneyPlanTo = 0;

	void initBuyOperateBoard();
	void initSellOperateBoard();
	void initBuyCards();
	void initSellCards();
	void PlayGetMyHoursePriceAnimation(Ref* obj);
	void PlayGetMyHourseCardAnimation();
	void earnByMoneyCard(Ref* pObj);

	void turnToSellStateUI(Ref* pObj);

	MenuItemImage* m_pCallButton;
	MenuItemImage* m_pPassButton;
	MenuItemImage* m_pSellButton;

	// Button Event
	void onAddButtonClick(Ref* obj);
	void onSubButtonClick(Ref* obj);
	void onCallButtonClick(Ref* obj);
	void onPassButtonClick(Ref* obj);
	void onSellButtonClick(Ref* obj);
public:
	CREATE_FUNC(OperateBoard);
};

